import request from '@/utils/request'

// const sysApi = '/cloud-system'
const sysApi = process.env.VUE_APP_SYS_API

/**
 * 用户登录
 * @param data
 * @returns {AxiosPromise}
 */
export const login = (data) => {
  return request({
    url: `${sysApi}/login`,
    method: 'POST',
    data
  })
}

/**
 * 用户退出
 * @returns {AxiosPromise}
 */
export const logout = () => {
  return request({
    url: `${sysApi}/logout`,
    method: 'POST'
  })
}

/**
 * 刷新Token
 * @returns {AxiosPromise}
 */
export const refresh = () => {
  return request({
    url: `${sysApi}/refresh`,
    method: 'POST'
  })
}

/**
 * 用户信息
 * @returns {AxiosPromise}
 */
export const profile = () => {
  return request({
    url: `${sysApi}/user/profile`,
    method: 'GET'
  })
}

/**
 * 获取用户能访问的路由
 * @returns {AxiosPromise}
 */
export const getRoutes = () => {
  return request({
    url: `${sysApi}/menu/localTrees`,
    method: 'GET'
  })
}

/**
 * 获取用户权限操作按钮
 * @returns {AxiosPromise}
 */
export const getPermissions = () => {
  return request({
    url: `${sysApi}/menu/localButton`,
    method: 'GET'
  })
}

